import request from '@/utils/request'

export function getQuestionsApi(params) {
  return request({
    url: 'http://hmmm-api.itheima.net/questions',
    method: 'get',
    params
  })
}

// 精选题库列表
export function getQuestionsChoiceApi(params) {
  return request({
    url: 'http://hmmm-api.itheima.net/questions/choice',
    method: 'get',
    params
  })
}

// 组题列表
export function getQuestionsRandomsApi(params) {
  return request({
    url: 'http://hmmm-api.itheima.net/questions/randoms',
    method: 'get',
    params
  })
}

// 基础题库添加
export function postQuestionsApi(data) {
  return request({
    url: 'http://hmmm-api.itheima.net/questions',
    method: 'post',
    data
  })
}

// 精选题库上下架
export function postQuestionschoiceApi(id, publishState) {
  return request({
    url: `http://hmmm-api.itheima.net/questions/choice/${id}/${publishState}`,
    method: 'post'
  })
}

// 列表删除(通用)
export function postQuestionsRandomsApi(id) {
  return request({
    url: `http://hmmm-api.itheima.net/questions/${id}`,
    method: 'delete'
  })
}

// 将基础题加入精选
export function postQuestionsChoiceApi(id) {
  return request({
    url: `http://hmmm-api.itheima.net/questions/choice/${id}/1`,
    method: 'PATCH'
  })
}

// 将基础题库修改
export function putQuestionsApi(id) {
  return request({
    url: `http://hmmm-api.itheima.net/questions/${id}`,
    method: 'put'
  })
}

// const obj = {
//   addDate: '2023-04-13T06:21:26.000Z',
//   answer: '<p>23123</p>',
//   catalogID: 7,
//   chkDate: '2023-04-13T06:22:28.000Z',
//   chkRemarks: '儿童',
//   chkState: 1,
//   chkUserID: 2,
//   city: '新荣区',
//   creatorID: 2,
//   difficulty: '3',
//   direction: '互联网',
//   directoryName: 'vue基础',
//   enterpriseID: 13,
//   id: 59,
//   isChoice: 1,
//   number: 'clgeqfkxf016qyi1fgp3hd2yl',
//   options: [
//     { id: 268, questionsID: 59, code: 'A', title: '', img: '', isRight: false },
//     { id: 269, questionsID: 59, code: 'B', title: '', img: '', isRight: false },
//     { id: 270, questionsID: 59, code: 'C', title: '', img: '', isRight: false },
//     { id: 271, questionsID: 59, code: 'D', title: '', img: '', isRight: false }
//   ],
//   province: '大同市',
//   publishDate: '2023-04-13T06:22:52.000Z',
//   publishState: 0,
//   question: '<p>呃呃呃</p>',
//   questionType: '1',
//   remarks: '11',
//   subjectID: 4,
//   subjectName: '前端',
//   tags: '语言2',
//   videoURL: '1'
// }

// const obja = {
//   addDate: '2023-04-13T12:20:21.000Z',
//   answer: '<p>asdasd</p>',
//   catalogID: 1,
//   chkDate: null,
//   chkRemarks: null,
//   chkState: 0,
//   chkUserID: null,
//   city: '隆尧县',
//   creatorID: 2,
//   difficulty: '2',
//   direction: '互联网',
//   directoryName: 'java基础',
//   enterpriseID: 2,
//   id: 68,
//   isChoice: 0,
//   number: 'clgf3959y019gyi1ffgfhhjx7',
//   options: [
//     { id: 292, questionsID: 68, code: 'C', title: '', img: '', isRight: false },

//     { id: 291, questionsID: 68, code: 'B', title: '', img: '', isRight: false },

//     {
//       id: 290,
//       questionsID: 68,
//       code: 'A',
//       title: 'asdasdasd',
//       img: '',
//       isRight: true
//     },

//     { id: 293, questionsID: 68, code: 'D', title: '', img: '', isRight: false }
//   ],
//   province: '邢台市',
//   publishDate: '2023-04-13T12:20:21.000Z',
//   publishState: 1,
//   question: '<p>das</p>',
//   questionType: '2',
//   remarks: '',
//   subjectID: 1,
//   subjectName: 'java',
//   tags: 'mvc',
//   videoURL: 'asd'
// }
